// Plugins
import vue  from '@vitejs/plugin-vue';
import path from 'path';

// Utilities
import { defineConfig } from 'vite';
import electron         from 'vite-plugin-electron';
import vuetify          from 'vite-plugin-vuetify';

// @link https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    electron([
      {entry: 'electron/main.ts'},
      {entry: 'electron/preload.ts'},
    ]),
    vue(),
    // @see https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
    vuetify({
      autoImport: true,
      styles: {
        configFile: 'src/settings.scss',
      },
    }),
  ],
  define: {'process.env': {}},
  resolve: {
    alias: [
      {find: '@', replacement: path.resolve(__dirname, 'src')},
      // webstorm 2021.2.1 似乎只能识别 @use '~'
      {find: /^~(.*)$/, replacement: path.resolve(__dirname, 'node_modules/$1')},
    ],
    extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
  },
  //
  server: {
    host: true,
    port: 80,
  },
  preview: {
    port: 8080,
  },
});
